<template>
  <div class="container">
    <!-- 面包屑 导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片 -->
    <el-card class="box-card">
      <el-table
        :data="QxtableData"
        border
        style="width: 100%"
      >
        <el-table-column
          type="index"
          width="50"
        >
        </el-table-column>

        <el-table-column
          prop="authName"
          label="权限名称"
        >
        </el-table-column>

        <el-table-column
          prop="path"
          label="路径"
        >
        </el-table-column>

        <!-- 权限等级 B -->
        <el-table-column
          prop="level"
          label="权限等级"
        >
          <!-- scope.row.level -->
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.level == 0"
              type="primary"
              plain
              size="mini"
            >一级</el-button>
            <el-button
              v-else-if="scope.row.level == 1"
              type="success"
              plain
              size="mini"
            >二级</el-button>
            <el-button
              v-else
              type="warning"
              plain
              size="mini"
            >三级</el-button>
          </template>

        </el-table-column>
        <!-- 权限等级 E -->

      </el-table>

    </el-card>

  </div>
</template>

<script>
export default {
  data() {
    return {
      token: '',
      QxtableData: []
    }
  },
  created() {
    this.token = window.sessionStorage.getItem('token')
    this.getQxDataList()
  },
  methods: {
    // 获取权限列表
    async getQxDataList() {
      const { data: res } = await this.$axios.get('rights/' + 'list', {
        headers: {
          'Authorization': this.token
        }
      })
      if (res.meta.status !== 200) {
        this.$message.error(res.meta.msg)
        return
      }

      this.QxtableData = res.data

      console.log(res)
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
}
</style>